package com.bzkj.web.controller.basic;

import com.bzkj.basicinfo.domain.basic.BillsTypeMapEntity;
import com.bzkj.basicinfo.service.BillsTypeMapService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.domain.R;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Date 2025/01/17 14:46:59
 * @description 单据类型二次分类
 */
@Api("单据类型管理")
@RestController
@RequestMapping("bills/type/map")
public class BillsTypeMapController
{
    @Autowired
    private BillsTypeMapService billsTypeMapService;

    /**
     * 获取单据类型二次分类列表
     */
    @ApiOperation("查询接口")
    @GetMapping("findBillsTree")
    public R findBillsTree()
    {
        return billsTypeMapService.findBillsTree();
    }

    /**
     * 新增单据二次分类信息
     *
     * @param entity
     * @return
     */
    @ApiOperation("新增接口")
    @PostMapping("saveBills")
    @LogC(title = "单据类型", businessType = BusinessType.INSERT, pkFieldNames = "id",
            tableNames = "bills_type_map",content = "' 单据类型名称：'+#entity.name"
    )
    public AjaxResult saveBills(@RequestBody BillsTypeMapEntity entity)
    {
        return billsTypeMapService.saveBills(entity);
    }
    /**
     * 修改单据二次分类信息
     *
     * @param entity
     * @return
     */
    @ApiOperation("修改接口")
    @PutMapping("updateBills")
    @LogC(title = "单据类型", businessType = BusinessType.UPDATE, pkFieldNames = "id",
            tableNames = "bills_type_map",content = "' 单据类型名称：'+#entity.name"
    )
    public AjaxResult updateBills(@RequestBody BillsTypeMapEntity entity)
    {
        return billsTypeMapService.updateBills(entity);
    }

    /**
     * 修改二次分类状态
     * @param id
     * @return
     */
    @ApiOperation("修改状态接口")
    @PutMapping("putBillsEnableStatus")
    @LogC(title = "单据类型", businessType = BusinessType.UPDATE, pkFieldNames = "id",
            tableNames = "bills_type_map"
    )
    public R putBillsEnableStatus(@RequestParam("id") Integer id,@RequestParam("enableStatus") Integer enableStatus)
    {
        return billsTypeMapService.putBillsEnableStatus(id,enableStatus);
    }

}
